import { UserState } from "@/stores/interface";

// 请求响应参数（不包含data）
export interface Result {
  code: string;
  message: string;
}

// 请求响应参数（包含data）
export interface ResultData<T = any> extends Result {
  data: T;
}

// 分页响应参数
export interface ResPage<T> {
  list: T[];
  pageNum: number;
  pageSize: number;
  total: number;
}

// 分页请求参数
export interface ReqPage {
  pageNum: number;
  pageSize: number;
}

// 文件上传模块
export namespace Upload {
  export interface ResFileUrl {
    fileUrl: string;
  }
}

// 登录模块
export namespace Login {
  export interface ReqLoginForm {
    username: string;
    password: string;
  }
  export interface ResLogin {
    token: string;
    userObj: UserState["userInfo"];
  }
  // 用户权限
  export interface ResAuth {
    buttonList: Array<string>;
    menuList: Array<string>;
    roleList: Array<string>;
  }
  export interface ResAuthButtons {
    [key: string]: string[];
  }
}

// 用户管理模块
export namespace User {
  export interface ReqUserParams extends ReqPage {
    username: string;
    gender: number;
    idCard: string;
    email: string;
    address: string;
    createTime: string[];
    status: number;
  }

  export interface ReqChangePassword {
    username: string;
    lodPassword: string;
    newPassword: string;
  }

  export interface ResUserList {
    id?: string;
    menuSet?: string;
    name?: string;
    remark?: string;
    statusName?: string;
    uptime?: string;
    username?: string;
    douser?: string;
    password?: string;
    status?: number;
    mobile?: number;
  }
  export interface ResStatus {
    userLabel: string;
    userValue: number;
  }
  export interface ResGender {
    genderLabel: string;
    genderValue: number;
  }
  export interface ResDepartment {
    id: string;
    name: string;
    children?: ResDepartment[];
  }
  export interface ResRole {
    id: string;
    name: string;
    children?: ResDepartment[];
  }
}

export namespace Role {
  export interface ReqSave {
    id?: string;
    name?: string;
    remark?: string;
    systemCode?: string;
  }

  export interface ReqEdit {
    roleId?: number;
    userIds?: string;
    remark?: string;
  }

  export interface ResRoleList extends ReqSave {
    id?: string;
    sysFlag?: string;
    status?: number;
    userList?: User.ResUserList[];
    userIdStr?: string;
    userNameStr?: string;
    userIds?: Array<number>;
  }

  export interface operateListProp {
    id: number;
    systemCode?: string;
    code?: string;
    name?: string;
    type?: number;
    sortOrder?: number;
    pid?: number;
    subcount?: number;
    status?: number;
    remark?: string;
    checked: boolean;
    isChecked?: boolean;
  }

  export interface Menu {
    firstMenuId: number;
    firstMenuCode: string;
    firstMenu: string;
    secondMenuId: number;
    secondMenuCode: string;
    secondMenu: string;
    children: number;
    operateList: operateListProp[];
    rowSpan: number;
    checkedSecondMenu: boolean;
    checkedFirstMenu: boolean;
    isCheckedFirstMenu: boolean;
    isCheckedSecondMenu: boolean;
  }

  export interface ReqRoleMenuSave {
    roleId: number;
    menus: RoleMenuSaveProp[];
  }

  export interface RoleMenuSaveProp {
    firstMenuId: number;
    secondMenuId: number;
    isCheckedFirstMenu: string;
    isCheckedSecondMenu: string;
    operateList: SaveOperateListProp[];
  }

  export interface SaveOperateListProp {
    id: number;
    isChecked: string;
  }
}
